/**
 * @author JeffYoung
 * @create 2017年3月23日
 */
package com.scau.action;

import java.util.List;

import net.sf.json.JSONArray;

import org.apache.log4j.Logger;

import com.scau.service.IStoreInfoService;
import com.scau.vo.StoreInfo;

public class StoreInfoAction extends SuperAction{
	private static final long serialVersionUID = 1L;
	public static Logger log = Logger.getLogger(StoreInfo.class);
	private String result;// 属性result，用于异步传输数据交互
	
	private IStoreInfoService storeInfoService;
	private StoreInfo storeInfo;
	
	//添加店铺信息
	/*public String saveStoreInfo(){
		StoreInfo si = getStoreInfo();
		System.out.println("添加店铺：" + si.getName());
		if (storeInfoService.saveStoreInfo(si)) {
			return "success";
		}else 
			return "error";
	}*/
	
	//删除店铺信息
	/*public String deleteStoreInfo(){
		StoreInfo si = getStoreInfo();
		System.out.println("删除店铺：" + si.getName());
		if (storeInfoService.deleteStoreInfo(si.getId())) {
			return "success";
		} else
			return "error";
	}*/
	
	//查看店铺信息
	public String listStoreInfo(){
		List<StoreInfo> storeInfoList = storeInfoService.listStoreInfo();
		System.out.println("店铺信息:" + storeInfoList);
		// 使用json方式返回值,toString必须
		JSONArray jsonArray = JSONArray.fromObject(storeInfoList.toString());
		System.out.println(storeInfoList.toString());
		result = jsonArray.toString();
		return "success";

	}
	
	//修改店铺信息
	public String updateStoreInfo(){
		StoreInfo si = getStoreInfo();
		System.out.println("修改店铺：" + si.getName());
		if (storeInfoService.updateStoreInfo(si)) {
			return "success";
		} else
			return "error";
	}
	
	// get,set 方法
	public IStoreInfoService getStoreInfoService() {
		return storeInfoService;
	}

	public void setStoreInfoService(IStoreInfoService storeInfoService) {
		this.storeInfoService = storeInfoService;
	}

	public StoreInfo getStoreInfo() {
		return storeInfo;
	}

	public void setStoreInfo(StoreInfo storeInfo) {
		this.storeInfo = storeInfo;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	
}
